﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ucRecvFileDetail.ascx.cs" Inherits="RecvFile_ucRecvFileDetail" %>
<%@ Register Assembly="YYWebControl" Namespace="YYWebControl.YYSimpleCalendar" TagPrefix="YYWebControl" %>

<script language="javascript" type="text/javascript">
    var caseIndexId = '<%= txtCaseIndex.ClientID %>';
    var id_CustomerName = '<%= txtCustomer.ClientID %>';
    var id_hfCustomerID = '<%= hfCustomerID.ClientID %>';
    var id_hfCaseID = '<%= hfCaseID.ClientID %>';

    function openSearchCaseDialog() {
        var url = "Cases/GetCaseIndexDlg.aspx";
        if (window.parent && window.parent.document && window.parent.document.openDialog) {
            window.parent.document.openDialog(url, "选择案件", callBack, 500, 300);
        }
    }
    function openSearchCustomerDialog() {
        var url = "Customer/GetCustomerDlg.aspx";
        if (window.parent && window.parent.document && window.parent.document.openDialog) {
            window.parent.document.openDialog(url, "选择客户", getCustomerCallBack, 700, 400);
        }
    }
    function callBack(type, key, jsonData) {
        if (type == 1) {
            getx(caseIndexId).value = jsonData.caseIndex;
            getx(id_hfCaseID).value = jsonData.id;
            if (jsonData.customerID) {
                getx(id_CustomerName).value = jsonData.customerName;
                getx(id_hfCustomerID).value = jsonData.customerID;
            }
            else {
                getx(id_CustomerName).value = "";
                getx(id_hfCustomerID).value = "";
            }
        }
    }
    function getCustomerCallBack(type, key, value) {
        if (type == 1) {
            getx(id_hfCustomerID).value = value.id;
            getx(id_CustomerName).value = value.name;
        }
    }
    function clearCaseIndex() {
        getx(caseIndexId).value = "";
    }
    function clearCustomerIndex() {
        getx(id_CustomerName).value = "";
        getx(id_hfCustomerID).value = "";
    }
    //////////////////////////////////////////////////////////////////////
    // UI 控制
    function enableChildrenLinks(enabled, element) {
        var nodes = element.getElementsByTagName("a");
        if (nodes) {
            for (var i = 0; i < nodes.length; i++) {
                if (!nodes[i].oldHref) {
                    nodes[i].oldHref = nodes[i].href;
                }
                nodes[i].disabled = !enabled;
                if (enabled)
                    nodes[i].href = nodes[i].oldHref;
                else
                    nodes[i].href = "javascript:void(0);";
            }
        }
    }
    function onRFSourceChanged() {
        var txtCustomer = getx("<%= txtCustomer.ClientID %>");
        var drpOffice = getx("<%= drpOffice.ClientID %>");
        var source = getx("<%= drpSource.ClientID %>");
        var isOffice = false;
        if (source.options[0].selected) {
            isOffice = true;
        }

        txtCustomer.disabled = isOffice;
        drpOffice.disabled = !isOffice;
        enableChildrenLinks(!isOffice, txtCustomer.parentNode);
    }
</script>
<table style="width:99%;">
    <tr style="height:1px; line-height:1px;">
        <td style="width:80px;"></td>
        <td style="width:200px;"></td>
        <td></td>
    </tr>
    <tr>
        <td>收文名称</td>
        <td><asp:TextBox runat="server" ID="txtRFName" CssClass="conint" Width="300px" ReadOnly="true"></asp:TextBox>
            <asp:HiddenField runat="server" ID="hfRFIndex" />
        </td>
        <td><asp:RequiredFieldValidator ID="RequiredFieldValidator1" 
                runat="server" ErrorMessage="必需选择一个收文" ControlToValidate="txtRFName" 
                Display="Dynamic" EnableViewState="False" SetFocusOnError="True" 
                ValidationGroup="submit"></asp:RequiredFieldValidator></td>
    </tr>
    <tr>
        <td>案件号</td>
        <td><asp:TextBox runat="server" ID="txtCaseIndex" CssClass="conint" ReadOnly="true"></asp:TextBox>
            <asp:HiddenField runat="server" ID="hfCaseID" />
            <a href="javascript:openSearchCaseDialog();">选择</a>
            <a href="javascript:clearCaseIndex();">清除</a>
        </td>
        <td></td>
    </tr>
    <tr>
        <td>收文日</td>
        <td><YYWebControl:YYSimpleCalendar ID="txtRFDate" runat="server" CssClass="conint singleline" />
        </td>
        <td><asp:RequiredFieldValidator ID="RequiredFieldValidator2" 
                runat="server" ErrorMessage="必填" ControlToValidate="txtRFDate" 
                Display="Dynamic" EnableViewState="False" SetFocusOnError="true"
                ValidationGroup="submit"></asp:RequiredFieldValidator></td>
    </tr>
    <tr>
        <td>发文日</td>
        <td><YYWebControl:YYSimpleCalendar ID="txtSentFileDate" runat="server" CssClass="conint singleline" />
        </td>
        <td></td>
    </tr>
    <tr>
        <td>回复日</td>
        <td><YYWebControl:YYSimpleCalendar ID="txtAnswerDate" runat="server" 
                CssClass="conint singleline" />
        </td>
        <td></td>
    </tr>
    <tr>
        <td>收文来自</td>
        <td>
        <asp:DropDownList runat="server" ID="drpSource" Width="120px">
            <asp:ListItem Text="官方" Value="O"></asp:ListItem>
            <asp:ListItem Text="客户" Value="C"></asp:ListItem>
        </asp:DropDownList>
        </td>
        <td></td>
    </tr>
    <tr>
        <td>官方</td>
        <td>
            <asp:DropDownList runat="server" ID="drpOffice" DataSourceID="SqlDataSource1" 
                DataTextField="OfficeName" DataValueField="OfficeID" Width="120px" 
                ondatabound="drpOffice_DataBound">
                <asp:ListItem Text="" Value="0"></asp:ListItem>
            </asp:DropDownList>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                SelectCommand="SELECT [OfficeID], [OfficeName] FROM [TD_Office] WHERE ([OfficeType] = @OfficeType) ORDER BY [OfficeName]">
                <SelectParameters>
                    <asp:Parameter DefaultValue="T" Name="OfficeType" Type="String" />
                </SelectParameters>
            </asp:SqlDataSource>
        </td>
        <td></td>
    </tr>
    <tr>
        <td>客户</td>
        <td>
            <asp:TextBox runat="server" ID="txtCustomer" CssClass="conint singleline" ReadOnly="true"></asp:TextBox>
            <asp:HiddenField runat="server" ID="hfCustomerID" />
            <asp:PlaceHolder runat="server" ID="phSelectCustomer" Visible="false">
            <a href="javascript:openSearchCustomerDialog();">选择</a>
            <a href="javascript:clearCustomerIndex();">清除</a>
            </asp:PlaceHolder>
        </td>
        <td></td>
    </tr>
    <tr>
        <td>内容</td>
        <td>
        </td>
        <td></td>
    </tr>
</table>
<asp:TextBox runat="server" ID="txtContent" TextMode="MultiLine"></asp:TextBox>
<asp:Literal runat="server" ID="ltrCKEditor" EnableViewState="false"></asp:Literal>
